using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using MsTestExecutor.TestableAssemblyForUnitTests;

namespace BizTalk.BuildGenerator.Tasks.Tests.VisualStudio
{
    /// <summary>
    /// Tests for the mstestexecutor
    /// </summary>
    [TestClass]
    public class MsTestExecutorTests : MSBuildTest 
    {
        /// <summary>
        /// Tests the task
        /// </summary>
        [TestMethod]        
        public void ExecuteTest()
        {
            //Simply here to ensure 
            var t = new UnitTest1();
            t.TestMethod1();

            const string arguments = "MsTestExecutor.msbuild /t:Build";
            var result = RunMSBuild(arguments);
            Assert.IsTrue(result == 0, "The MSBuild Task failed.");
        }

        /// <summary>
        /// Pretest setup
        /// </summary>
        [TestInitialize]
        public void Setup()
        {
            GetFileAndWriteToPath("BizTalk.BuildGenerator.Tasks.Tests.VisualStudio.MsTestExecutor.msbuild", "MsTestExecutor.msbuild");            
        }
        /// <summary>
        /// Cleans after test
        /// </summary>
        [TestCleanup]
        public void CleanUp()
        {
            File.Delete("MsTestExecutor.msbuild");            
        }
    }
}
